-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a info experimental func walk logic #136
Conversation
walk.go
Outdated
@@ -393,6 +393,9 @@ func (s *PromQLSmith) walkVariadicFunctions(expr *parser.Call) { | |||
case "round": | |||
expr.Args[0] = s.Walk(expr.Func.ArgTypes[0]) | |||
expr.Args[1] = &parser.NumberLiteral{Val: float64(s.rnd.Intn(10))} | |||
case "info": | |||
expr.Args[0] = s.Walk(expr.Func.ArgTypes[0]) | |||
expr.Args[1] = s.Walk(expr.Func.ArgTypes[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second argument has to be a vector selector.
If you do s.Walk(<vector-type>)
it will generate an expression which has a result value type to be vector but it can be a different expression like function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can have a dedicated walkInfo
function. The second parameter can be either skipped or kept based on rand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yeya24
Thanks. I have fixed it.
9162596
to
4d95884
Compare
walk_test.go
Outdated
p.walkInfo(expr) | ||
require.Equal(t, parser.ValueTypeVector, expr.Args[0].Type()) | ||
if len(expr.Args) == 2 { | ||
require.Equal(t, parser.ValueTypeVector, expr.Args[1].Type()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expr.Args[1].Type()
only makes sure the response type is vector
.
For this funciton, we need to make sure that expr.Args[1]
itself is a vector selector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot.
I'm not familiar with the term.
Is the vector selector
like a matcher
which can produce a vector
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. What you did is exactly what I want as this is what upstream Promql engine uses
_, ok := expr.Args[1].(*parser.VectorSelector)
Signed-off-by: kade.lee <[email protected]>
4d95884
to
673cd2d
Compare
We probably need to bump golang-ci lint. I will merge this PR first and bump its version in another PR |
Add an
info
experimental func to walk logic.